package soundsystem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CDPlayer {
    //@Autowired   //( 1 )
    private  CompactDisc cd;

    public CDPlayer() {
        super();
        System.out.println("CDPlayer无参构造方法。。");
    }


    @Autowired  // 将@Autowired 放在位置（1）效果一样
    public CDPlayer(CompactDisc cd) {
       this.cd=cd;
        System.out.println("CDPlayer有参构造方法。。");
    }
    public void play(){
        cd.play();
    }
}
